<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  {{include './header.html'}}
  <div class="container">
    <form action="/api/publish" method='post'>
      <div class="form-group">
         <label for="">标题：</label>
         <input type="text" class="form-control" name="title" required>
      </div>
      <div class="form-group">
         <label for="">标签(多个标签名称以空格隔开))：</label>
         <input type="text" class="form-control" name="tag" required>
      </div>
      <div class="form-group">
        <label for="">内容：</label>
        <input type="text" class="form-control" name="content" required>
      </div>
      
      <button class="btn btn-primary form-control">发布</button>
    </form>
  </div>
  <script>
    
    $('form').submit(function(event){
      event.preventDefault()
      $.post('/api/publish',$(this).serialize(),(data)=>{
        alert(data.msg)
        if(data.code){
          location.href='/'
        }else{
          location.href='/publish'
        }
      })
    })
  </script>
</body>
</html>